<?php

namespace App\Http\Controllers\Api;

use App\Models\Sport;
use App\Models\User;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Monolog\Handler\IFTTTHandler;

class SportTestController extends ApiController
{

    private $uid = '';


    public function __construct(Request $request)
    {
      $this->uid = auth('api')->id();
    }
    //得到当前人详细的体侧数据
    public function getDetailSport(Request $request){
       $id = $request['id'];
       $res = Sport::getDetailSport($id);
       return self::returnAjax($res, 200, "当前人体测数据！");
    }
    //修改体侧状态
    public function switchSport(Request $request){
        $status = $request['status'];
        $res = User::switchSport($this->uid,$status);
        if ($res){
            return self::returnAjax('', 200, "修改成功");
        }else{
            return parent::ajaxReturn(201, new \stdClass(), '修改失败');
        }
    }
}
